/*
	created time:2018/4/12
	author:Chason
	describe:单张卡牌
*/
class Card  extends egret.Bitmap{
	public constructor(name:string) {
		super();
		let dian=name.indexOf(".");
		this.name=name.slice(dian+1);
		this.init(name);
	}

	private  stageWidth=egret.MainContext.instance.stage.stageWidth;
	private  stageHeight=egret.MainContext.instance.stage.stageHeight;

	//选中(出牌)状态--默认没选中
	public selected:boolean=false;
	//是否已经出牌了
	public isOut=false;
	//是否是本玩家自己--默认不是
	public isMe:boolean=false;
	//标识本卡牌---比如梅花4
	public name:string;





	public init(name){
		this.touchEnabled=true;
		this.anchorOffsetX=42.5;
		this.anchorOffsetY=58;
		this.texture=RES.getRes(name);
		//本玩家的点击扑克事件
		this.addEventListener(egret.TouchEvent.TOUCH_TAP,()=>{
			//是本玩家的卡牌
			if(this.isMe){
				//还没出牌
				if(!this.isOut){
					//还没选中状态
					if(!this.selected){
						this.selected=true;
						this.y=Basic.meCardInitY(this.stageHeight)-20;
					}else{
						this.selected=false;
						this.y=Basic.meCardInitY(this.stageHeight);
					}
					//播放点卡牌声音
					Music.musicOncePlay("SpecSelectCard_mp3");	
				}				
			}
		},this);
	}
}